//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package javax.vpncrypto.spec;

import java.security.spec.KeySpec;
import java.util.Arrays;

public class PBEKeySpec implements KeySpec {
    private char[] password;
    private byte[] salt = null;
    private int iterationCount = 0;
    private int keyLength = 0;

    public PBEKeySpec(char[] var1) {
        if (var1 != null && var1.length != 0) {
            this.password = (char[])var1.clone();
        } else {
            this.password = new char[0];
        }

    }

    public PBEKeySpec(char[] var1, byte[] var2, int var3, int var4) {
        if (var1 != null && var1.length != 0) {
            this.password = (char[])var1.clone();
        } else {
            this.password = new char[0];
        }

        if (var2 == null) {
            throw new NullPointerException("the salt parameter must be non-null");
        } else if (var2.length == 0) {
            throw new IllegalArgumentException("the salt parameter must not be empty");
        } else {
            this.salt = (byte[])var2.clone();
            if (var3 <= 0) {
                throw new IllegalArgumentException("invalid iterationCount value");
            } else if (var4 <= 0) {
                throw new IllegalArgumentException("invalid keyLength value");
            } else {
                this.iterationCount = var3;
                this.keyLength = var4;
            }
        }
    }

    public PBEKeySpec(char[] var1, byte[] var2, int var3) {
        if (var1 != null && var1.length != 0) {
            this.password = (char[])var1.clone();
        } else {
            this.password = new char[0];
        }

        if (var2 == null) {
            throw new NullPointerException("the salt parameter must be non-null");
        } else if (var2.length == 0) {
            throw new IllegalArgumentException("the salt parameter must not be empty");
        } else {
            this.salt = (byte[])var2.clone();
            if (var3 <= 0) {
                throw new IllegalArgumentException("invalid iterationCount value");
            } else {
                this.iterationCount = var3;
            }
        }
    }

    public final void clearPassword() {
        if (this.password != null) {
            Arrays.fill(this.password, ' ');
            this.password = null;
        }

    }

    public final char[] getPassword() {
        if (this.password == null) {
            throw new IllegalStateException("password has been cleared");
        } else {
            return (char[])this.password.clone();
        }
    }

    public final byte[] getSalt() {
        return this.salt != null ? (byte[])this.salt.clone() : null;
    }

    public final int getIterationCount() {
        return this.iterationCount;
    }

    public final int getKeyLength() {
        return this.keyLength;
    }
}
